{% extends "album/base.html" %}
{% from "macros/macro_pagination.html" import render_pagination %}

{% block title %}
    短剧剧集
{% endblock %}

{% block page_title %}
    剧集列表
{% endblock %}


{% block header_actions %}
    <div class="page-actions">
        <a href="{{ url_for('album_episode_info.create',album_id=album_info.get('id')) }}" class="btn btn-primary">
            <i class="fa fa-plus"></i> 新建
        </a>
    </div>
{% endblock %}

{% block body %}

    <!-- 搜索区域 -->
    <form id="queryForm" method="post" action="{{ url_for('album_episode_info.page',album_id=album_info.get('id')) }}">
        {{ form.csrf_token }}
        <div class="search-container">
            <div class="search-form">
                <div class="condition">
                    <label>{{ form.title.label }}</label>
                    <div class="filter-input">
                        {{ form.title() }}
                    </div>
                </div>
            </div>
            <div class="condition-more">
                <div class="condition" style="margin-right: 0;">
                    <button class="search-button" type="submit">
                        <i class="fa fa-search"></i>查询
                    </button>
                    <button class="reset-button" type="button" onclick="clearForm()">
                        <i class="fas fa-times"></i>重置
                    </button>
                </div>
            </div>
        </div>
    </form>
    <!-- 数据列表 -->
    <div class="data-table-container">
        <table class="data-table">
            <thead>
            <tr>
                <th>ID</th>
                <th>剧集标题</th>
                <th>剧集集数</th>
                <th>封面图</th>
                <th>视频素材</th>
                <th>抖音剧集ID</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for item in pagination.items %}
                <tr>
                    <td>{{ item.get('id') }}</td>
                    <td>{{ item.get('title') }}</td>
                    <td>{{ item.get('seq_index') }}</td>
                    <td>
                        {% for cover in item.get('covers') %}
                            <a href="javascript:previewShow('image','{{ cover.get('file_name') }}','{{ cover.get('title') }}')">
                                {{ cover.get('file_name') }}
                            </a>
                            <br/>
                        {% endfor %}
                    </td>
                    <td>
                        <a href="javascript:previewShow('video','{{ item.get('video_library').get('file_name') }}','{{ item.get('video_library').get('title') }}')">
                            {{ item.get('video_library').get('file_name') }}</a>
                    </td>
                    <td>{{ item.get('dy_episode_id') if item.get('dy_episode_id') else '' }}</td>
                    <td>{{ item.get('create_time') }}</td>
                    <td class="action-buttons">
                        <button class="action-btn edit-btn"
                                onclick="window.location.href='{{ url_for('album_episode_info.edit',id=item.get('id'),album_id=album_info.get('id')) }}'">
                            编辑
                        </button>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    <!-- 分页控件 -->
    {{ render_pagination(pagination, 'album_episode_info.page', form=form) }}
{% endblock %}